<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>新增车辆</title>
    <link rel="stylesheet" href="../../../../start/layui/css/layui.css" media="all">
    <script src="../../../../start/layui/layui.js"></script>
</head>
<body>
<form class="layui-form layui-form-pane" >
    <div class="layui-form-item">
        <label class="layui-form-label">所属分站</label>
        <div class="layui-input-block" style="width:350px">
            <select name="subId" id="subId">
                <option value="">---请选择---</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">运输线路1-2</label>
        <div class="layui-input-block" style="width:350px;float:left;margin-left:0px">
            <input type="text" name="trafficcircuitone" placeholder="请输入运输线路1-2" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">运输线路2-1</label>
        <div class="layui-input-block" style="width:350px;float:left;margin-left:0px">
            <input type="text" name="trafficcircuittwo" placeholder="请输入运输线路2-1" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">车辆位置</label>
        <div class="layui-input-block" style="width:350px;float:left;margin-left:0px">
            <input type="text" name="location" placeholder="请输入车辆位置" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">车辆牌照</label>
        <div class="layui-input-block" style="width:350px;float:left;margin-left:0px">
            <input type="text" name="licensetag" placeholder="请输入车辆牌照" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">司机手机号</label>
        <div class="layui-input-block" style="width:350px;float:left;margin-left:0px">
            <input type="text" name="phone" placeholder="请输入司机手机号" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">挂车拍照号</label>
        <div class="layui-input-block" style="width:350px;float:left;margin-left:0px">
            <input type="text" name="trailer" placeholder="请输入挂车拍照号" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">车辆所有权</label>
        <div class="layui-input-block" style="width:350px;float:left;margin-left:0px">
            <input type="text" name="vehicleproperty" placeholder="请输入车辆所有权" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">车主姓名</label>
        <div class="layui-input-block" style="width:350px;float:left;margin-left:0px">
            <input type="text" name="ownername" placeholder="请输入车主姓名" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">车主身份证</label>
        <div class="layui-input-block" style="width:350px;float:left;margin-left:0px">
            <input type="text" name="identitycard" placeholder="请输入车主身份证" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">车主地址</label>
        <div class="layui-input-block" style="width:350px;float:left;margin-left:0px">
            <input type="text" name="owneraddress" placeholder="请输入车主地址" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">最大载重单位吨</label>
        <div class="layui-input-block" style="width:350px;float:left;margin-left:0px">
            <input type="text" name="maximumload" placeholder="请输入最大载重单位吨" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">评价备注</label>
        <div class="layui-input-block" style="width:350px;float:left;margin-left:0px">
            <input type="text" name="remark" placeholder="请输入评价备注" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">车辆类型</label>
        <div class="layui-input-block" style="width:350px;float:left;margin-left:0px">
            <input type="text" name="vehicleType" placeholder="请输入车辆类型" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
</body>
</html>
<script>
    layui.use(['form','layer'], function(){
        var form = layui.form;
        var layer = layui.layer;
        var $ = layui.jquery;

        $.ajax({
            type:"post"
            ,url:"../../../../../getAllSubstation.action"
            ,dataType:"json",
            success:function(data){
                for (var i=0;i<data.length;i++){
                    //循环添加选项
                    $("#subId").append("<option value="+data[i].subId+">"+data[i].subName+"</option>");
                }
                form.render();
            }
        });

        //监听提交：提交事件
        form.on('submit(formDemo)', function(data){
            $.ajax({
                type:"post"
                ,url:"../../../../../insertDriver.action"
                ,data:data.field
            });
            setTimeout(function(){//设置定时器
                window.parent.location.reload();//刷新父页面
                //获取当前窗口名称
                //当你在iframe页面关闭自身时
                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                parent.layer.close(index); //再执行关闭
            },500);
            return false;
        });

    });

</script>
